<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Auto Parts</title>
<link rel="stylesheet" type="text/css" href="../../css/mokstyle.css" />
		<style type="text/css">
		a:link {text-decoration: none;}
		a:visited {text-decoration: none;}
		a:active {text-decoration: none;}
		a:hover {text-decoration:underline;padding-bottom:8px;border-bottom:1 solid black}
		</style> 
		<script type="text/javascript">
			function change(id){
				if(id=='history'){
					window.location = "/aasimp/mok/maintenance/odd_getOdd"
				}else{
					document.getElementById('a2').style.textDecoration = 'underline';
					document.getElementById('a1').style.textDecoration = 'none';
					document.getElementById(id).style.display = 'block';
					document.getElementById('but').style.display = 'block';
					document.getElementById('history').style.display = 'none';
					var d = new Date();
					var year = d.getFullYear();
					var month = d.getMonth() + 1;
					if((month/10)<1){
						month = "0"+month; 
					}
					var date = d.getDate();
					if((date/10)<1){
						date = "0"+date; 
					}
					var hour = d.getHours() ;
					if((hour/10)<1){
						hour = "0"+hour; 
					}
					var minutes = d.getMinutes() ;
					if((minutes/10)<1){
						minutes = "0"+minutes; 
					}
					var seconds = d.getSeconds() ;
					if((seconds/10)<1){
						seconds = "0"+seconds; 
					}
					document.getElementById('odd_id').value = year+month+date+hour+minutes+seconds;
					document.getElementById('begintime').value = "";
					document.getElementById('company').value = "";
					document.getElementById('vin').value = "";
					document.getElementById('tel').value = "${eauser.tel }";
					document.getElementById('email').value = "${eauser.email }";
					document.getElementById('remark').value = "";
					document.getElementById('create_date').value = year+"-"+month+"-"+date;
				}
			}
			function choosecompany() {
		        var returnValue = window.showModalDialog("/aasimp/mok/maintenance/info_getCompanys", null, "dialogHeight:400px; dialogWidth:600px; help:no; status:no");
		        if (returnValue==null){
		         	return;
		        } 
		        document.getElementById("company").value = returnValue;
    		}
    		function submit_odd(){
    			var time = document.getElementById('begintime').value;
    			var d = new Date();
    			if(time==''){
    				alert("预约日期不能为空！");
    				return;
    			}
    			if(Date.parse(time)<Date.parse(d)){
    				alert("预约日期不能在今天之前！");
    				return;
    			}
    			var company = document.getElementById('company').value;
    			if(company==''){
    				alert("请预约一家公司！");
    				return;
    			}
    			var vin = document.getElementById('vin').value;
    			if(vin==''){
    				alert("车辆识别号不能为空！");
    				return;
    			}
    			document.getElementById('oddForm').submit();
    		}
    		function init(){
    			if("${odds}"!=""){
					document.getElementById('a1').style.textDecoration = 'underline';
					document.getElementById('history').style.display = 'block';
    			}
    			if("${oneOdd}"!=""){
					document.getElementById('tel').value = "${oneOdd.persontel}";
					document.getElementById('email').value = "${oneOdd.personemail}";
					document.getElementById('remark').innerHTML = "${oneOdd.remark}";
					document.getElementById('new').style.display = 'block';
					document.getElementById('but').style.display = 'none';
    			}
    			if("${message}"!=""){
					alert("${message}");
				}
				
    		}
    		function deleteodd(id){
    			var a = window.confirm("确认删除？");
    			if(!a)return;
    			window.location="/aasimp/mok/maintenance/odd_deleteodd?oddId="+id;
    		}
    		function showodd(id){
    			window.location="/aasimp/mok/maintenance/odd_showodd?oddId="+id;
    		}
		</script>

</head>
<body onload="init();">

<div  id="wrap">
 	<div class="header">
       		<div class="logo"><a href="/aasimp/mok/maintenance/index_getMtInfo"><img src="../../images/logo.gif" alt="" title="" border="0" /></a></div>            
        <div id="menu">
            <ul>                                                                       
            <li><a href="/aasimp/mok/maintenance/index_getMtInfo">首页</a></li>
            <li><a href="/aasimp/mok/maintenance/info_getcompany">个人资料</a></li>
            <li class="selected"><a href="/aasimp/mok/maintenance/odd_getOdd" >维修申请</a></li>
            <li><a href="/aasimp/mok/maintenance/approve_showApprove">审批维修</a></li>
            <li><a href="/aasimp/mok/maintenance/mt_showmts">维修记录</a></li>
            <li><a href="sendInfo.jsp">信息发布</a></li>
            <li><a href="/aasimp/mok/maintenance/report_showMtReport">报表统计</a></li>
            </ul>
        </div>  
       </div> 
       
       <div class="center_content" style="background-color:#FFFFFF;">
       	<div class="left_content" style="width: 880px;height: 100%;">
        	<div class="crumb_nav">
            <a href="/aasimp/mok/maintenance/index_getMtInfo">home</a> &gt;&gt; 维修申请
            </div>
           <div class="title"><span class="title_icon"><img src="../../images/bullet1.gif" alt="" title="" /></span>
            <a id="a1" href="javascript:void(0)" onclick="change('history')" style="text-decoration: none">查看历史申请单</a>
            <a id="a2" href="javascript:void(0)"  onclick="change('new')" style="text-decoration:none">填写维修申请单</a>
            </div>
			<center>
        	<div class="feat_prod_box_details" id="history" style="display: none;">
            <p class="details">
            </p>
                 <form name="register" action="#">          
                    <table width="100%"  border="1" align="center" cellspacing="1">
                    	<tr>
                    		<th>预约单号</th>
                    		<th>创建日期</th>
                    		<th>预约日期</th>
                    		<th>预约公司</th>
                    		<th>车辆识别号</th>
                    		<th>状态</th>
                    		<th>操作</th>
                    	</tr>
                    	<c:forEach var="odd" items="${odds}">
						  <tr onDblClick="showRow('${odd.oddId }')">
						    <td align="center">${odd.oddId }</td>
						    <td align="center"><fmt:formatDate value="${odd.createDate }" pattern="yyyy年MM月dd日"/></td>
						    <td align="center"><fmt:formatDate value="${odd.oddDate }" pattern="yyyy年MM月dd日"/></td>
						    <td align="center">${odd.oddCompany }</td>
						    <td align="center">${odd.vin }</td>
						    <td align="center">
						    <c:if test="${odd.status=='1'}">新</c:if>
						    <c:if test="${odd.status=='2'}">申请通过</c:if>
						    <c:if test="${odd.status=='3'}">申请未通过</c:if>
						    </td>
                    		<td><a href="javascript:void(0)" onclick="showodd('${odd.oddId}')">查看</a>
                    		<a href="javascript:void(0)" onclick="deleteodd('${odd.oddId}')">删除</a></td>
						  </tr>
					 	 </c:forEach>
                    </table>
                  </form>
            </div>	
            
        	<div class="feat_prod_box_details" id="new" style="display: none;">
            <p class="details">
            </p>
                 <form id="oddForm" name="register" action="/aasimp/mok/maintenance/odd_addOdd" method="post">          
                    <div class="form_row" style="width: 345px">
                    <label class="contact" style="width: 78px"><strong>预约单号：</strong></label>
                    <input name="odd_id" id="odd_id" value="${oneOdd.oddId }" type="text" class="contact_input" readonly="readonly"/>
                    </div>  

                    <div class="form_row" style="width: 345px">
                    <label class="contact" style="width: 78px"><strong>创建日期：</strong></label>
                    <input name="create_date" id="create_date" value="${oneOdd.createDate }" type="text" class="contact_input" readonly="readonly"/>
                    </div> 

                    <div class="form_row" style="height: 14px;width: 345px;">
                    <label class="contact" style="width: 78px"><strong>预约日期：</strong></label>
                    <input type="text" class="contact_input" value="${oneOdd.oddDate }" style="width: 215px" name="begintime" id="begintime" readonly="readonly"/>
       				<a href="javascript:void(0)" onclick="gfPop.fPopCalendar(document.getElementById('begintime'));return false;">
        			<img src="images/selectDate.gif" width="15" height="12" border="0" alt=""></a>              
                    </div> 

                    <div class="form_row" style="height: 14px;width: 345px">
                    <label class="contact" style="width: 78px"><strong>预约公司：</strong></label>
                    <input id="company" name="company" value="${oneOdd.oddCompany }" type="text" class="contact_input" style="width: 215px" readonly/>
                    <a href="javascript:void(0)" onclick="choosecompany();return false;">
                    <image src='images/selectDate.gif' width="15" height="12" border="0" alt=""></a>
                    </div>

                    <div class="form_row" style="width: 345px">
                    <label class="contact" style="width: 78px"><strong>车辆识别号：</strong></label>
                    <select id="vin" name="vin" style="width: 253px;">
                    <c:forEach var="carMain" items="${carMainInfo}">
	                    <option>${carMain.vin}</option>
	                </c:forEach>
                    </select>
                    </div>

                    <div class="form_row" style="width: 345px">
                    <label class="contact" style="width: 78px"><strong>手机：</strong></label>
                    <input id="tel" name="tel" value="${eauser.tel }" type="text"  style="width: 253px;" />
                    </div>

                    <div class="form_row" style="width: 345px">
                    <label class="contact" style="width: 78px"><strong>邮箱：</strong></label>
                    <input id="email" name="email" value="${eauser.email }" type="text" style="width: 253px;"/>
                    </div>

                    <div class="form_row" style="width: 345px">
                    <label class="contact" style="width: 78px"><strong>维修原因：</strong></label>
                    <textarea id="remark" name="remark" class="contact_input" cols="27" rows="3"></textarea>
                    </div>

                    <div class="form_row" style="width: 345px">
                    <input id="but" type="button" class="register" value="提交" onclick="submit_odd()"/>
                    </div>   
                  </form>
            </div>	</center>
            
          
            
        <div class="clear"></div>
        </div><!--end of left content-->
        
       <div class="clear"></div>
       </div><!--end of center content-->
       <div class="footer">
       	<div class="left_footer"><img src="../../images/footer_logo.gif" alt="" title="" /><br /> </div>
        <div class="right_footer">
       
        </div>
        
       
       </div>
       
  </div>     
<iframe width=174 height=189 name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="calendar/ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; left:-500px; top:0px;"></iframe>
</body>
</html>